package com.qingcloud.df.executor.enums;

import com.qingcloud.df.executor.queue.subscriber.AkkaSubcriber;
import com.qingcloud.df.executor.queue.subscriber.ComponentSubscriber;

/**
 * 组件通信类型
 *
 * @author yangfan
 * @date 2022/1/17 15:33
 */
public enum ComponentCommunicationEnum {

    /**
     * kafka
     */
//    KAFKA("kafka","kafkaPublisher", KafkaSubcriber.class),

    /**
     * akka
     */
    AKKA("akka","akkaPublisher", AkkaSubcriber.class),

    /**
     * 无通信方式
     */
    NULL(null,null, null),

    ;

    /**
     * 通信方式
     */
    public final String communicationType;

    /**
     * 发布者
     */
    private final String publisher;

    /**
     * 订阅者
     */
    private final Class<? extends ComponentSubscriber> subcriber;

    ComponentCommunicationEnum(String communicationType,String publisher,Class<? extends ComponentSubscriber> subcriber) {
        this.communicationType = communicationType;
        this.publisher = publisher;
        this.subcriber = subcriber;
    }

    public static ComponentCommunicationEnum findNameByCode(String communicationType) {
        for (ComponentCommunicationEnum type : ComponentCommunicationEnum.values()) {
            if (type.getCommunicationType().equals(communicationType)) {
                return type;
            }
        }
        return NULL;
    }

    public String getCommunicationType() {
        return communicationType;
    }

    public String getPublisher() {
        return publisher;
    }

    public Class<? extends ComponentSubscriber> getSubcriber() {
        return subcriber;
    }


}
